//
//  GroupListCell.m
//  ChangChat
//
//  Created by Cocoa on 2019/9/24.
//  Copyright © 2019 yibai. All rights reserved.
//

#import "GroupListCell.h"

@implementation GroupListCell


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self setupUI];
    }
    return self;
}
- (void)setupUI {
    
    self.iconImageView = UIImageView.new;
    self.nameLabel = [UILabel k_labelWithFontSize:15 textColor:UIColor.k_t2Color];
    self.nameLabel.highlightedTextColor = UIColor.k_t1Color;
    
    [self.pContentView addSubview:self.iconImageView];
    [self.pContentView addSubview:self.nameLabel];
    
    [self.iconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_offset(15);
        make.top.mas_offset(11);
        make.size.mas_equalTo(CGSizeMake(40, 40));
        make.bottom.mas_offset(-11);
    }];
    self.iconImageView.layer.cornerRadius = 20;
    self.iconImageView.layer.masksToBounds = YES;
    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.iconImageView.mas_right).offset(5);
        make.centerY.equalTo(self.iconImageView);
        make.right.mas_offset(-25);
    }];
    
    self.selectedBackgroundView = [[UIView alloc] initWithFrame:self.bounds];
    self.selectedBackgroundView.backgroundColor = UIColor.whiteColor;
    self.backgroundColor =
    self.contentView.backgroundColor = global_viewBackgroundColor;
    
    self.iconImageView.image = UIImage.k_imgName(@"placeholder_user");
    self.nameLabel.text = @"李四";
}

- (void)setGroup:(GroupItem *)group {
    _group = group;
    
    [self.iconImageView sd_setImageWithURL:group.avatar.toURL placeholderImage:UIImage.k_imgName(@"placeholder_user")];
    self.nameLabel.text = group.name;
}
@end
